#pragma once

#include "wxtl/Socket.h"
#include "IocpOperation.h"
#include "IocpIoBaseInitiator.h"


class AsyncIoBase : public I_Io
{

};

struct IocpOperation;

struct IocpSocketConnectRequest
{
	enum TypeEx{Connect = IocpIoRequest::_BaseRequestEnd + 1};

	IocpSocketConnectRequest()
		:port(0)
	{

	}

	IocpSocketConnectRequest(const char* addres, UINT port)
		:address(addres)
		,port(port)
	{
	}

	string address;
	UINT port;
};

class IocpServerSocket : public IocpIoBaseInitiator
{
public:
	IocpServerSocket(wxtl::Socket& socket);
	virtual ~IocpServerSocket();

	virtual bool ProcessIocpRequest();

	void Close();
	bool IsConnected();
	void Connect(const char* adr, UINT port);
	bool Validate()
	{
		return m_socket.isValid();
	}

private:
	wxtl::Socket m_socket;
	char m_outBuffer[1024];
	char m_inBuffer[1024];
	IocpSocketConnectRequest m_requestEx;
};